import Layout from '@/layout'

/*
 配合菜单栏使用router
 @alwaysShow : 控制 是否为一级菜单
 @name ： 路由的name
 @component : 路由组件
 @redirect ： 重定向
 @meta : 路由信息 icon： 菜单icon ，noCache：是否缓存页面，title：菜单标题
 @hidden : 是否在menu中隐藏该路由
*/
const sidebarRouters = [
  {
    alwaysShow:true,
    name:'System',
    path: '/system',
    component: Layout,
    redirect: 'noRedirect',
    meta:{ icon: "iconfont icon-xitongshezhi", noCache: false, title: "系统管理" },
    children: [
      {
        path: 'user',
        name: 'User',
        hidden: false,
        component: () => import(/* webpackChunkName: "user" */ '../views/system/user/index.vue'),
        meta:{icon: "iconfont icon-yonghuguanli1",noCache: false,title: "用户管理"}
      },
      {
        path: 'userLoginLog',
        name: 'UserLoginLog',
        hidden: false,
        component: () => import(/* webpackChunkName: "user" */ '../views/system/userLogs/index.vue'),
        meta:{icon: "iconfont icon-yonghuguanli1",noCache: false,title: "访问日志"}
      },
      {
        path: 'profile',
        name: 'Profile',
        hidden: true,
        component: () => import(/* webpackChunkName: "user" */ '../views/profile/index.vue'),
        meta:{icon: "el-icon-user-solid",noCache: false,title: "个人中心"}
      },
    ]
  },
  {
    alwaysShow:true,
    name:'Blog',
    path: '/blog',
    component: Layout,
    redirect: 'noRedirect',
    meta:{ icon: "iconfont icon-bokeblogger3", noCache: false, title: "博客管理" },
    children: [
      // 文章分类
      {
        path: 'classify',
        name: 'Classify',
        hidden: false,
        component: () => import(/* webpackChunkName: "blog" */ '../views/blog/classify/index.vue'),
        meta:{icon: "iconfont icon-wenzhangfenlei1",noCache: false,title: "文章分类"}
      },
      // 文章标签
      {
        path: 'tag',
        name: 'Tag',
        hidden: false,
        component: () => import(/* webpackChunkName: "blog" */ '../views/blog/tag/index.vue'),
        meta:{icon: "iconfont icon-biaoqian",noCache: false,title: "文章标签"}
      },
      // 文章管理
      {
        path: 'essay',
        name: 'Essay',
        hidden: false,
        component: () => import(/* webpackChunkName: "blog" */ '../views/blog/essay/index.vue'),
        meta:{icon: "iconfont icon-guanliwenzhang",noCache: false,title: "文章管理"}
      },
      // 文章编辑
      {
        path: 'essay/add',
        name: 'EssayAdd',
        hidden: true,  // 该路由不在menu列表显示
        component: () => import(/* webpackChunkName: "blog" */ '../views/blog/essay/edit.vue'),
        meta:{icon: "",noCache: false,title: "新增博客"}
      },
      {
        path: 'essay/update/:id?/:essayState?',
        name: 'EssayUpdate',
        hidden: true,  // 该路由不在menu列表显示
        component: () => import(/* webpackChunkName: "blog" */ '../views/blog/essay/edit.vue'),
        meta:{icon: "",noCache: false,title: "修改博客"}
      },
      {
        path: 'essay/preview/:id?',
        name: 'EssayPreview',
        hidden: true,  // 该路由不在menu列表显示
        component: () => import(/* webpackChunkName: "blog" */ '../views/blog/essay/preview.vue'),
        meta:{icon: "",noCache: false,title: "预览博客"}
      },

    ]
  }
]
// 页面默认公共router
const publicRoutes = [
  {
    path: '',
    component: Layout,
    redirect: 'index',
    children: [
      {
        path: 'index',
        component: (resolve) => require(['../views/index.vue'], resolve),
        name: 'index',
        meta: { title: '首页', icon: 'dashboard', noCache: true, affix: true }
      }
    ]
  },
  {
    path: '/redirect',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/redirect/:path(.*)',
        component: (resolve) => require(['@/views/redirect'], resolve)
      }
    ]
  },
  {
    path: '/login',
    component:  (resolve) => require(['@/views/login'], resolve),
    hidden: true,
    meta: { title: '登录'}
  },
  {
    path: '/homePage',
    component:  (resolve) => require(['@/views/homePage'], resolve),
    hidden: true
  },
]
const routes = sidebarRouters.concat(publicRoutes)
export {
  routes,
  sidebarRouters
}
